<?php
// | YBlog
// +----------------------------------------------------------------------
// | Copyright (c) 2008 http://www.yhustc.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: yhustc <yhustc@gmail.com>
// +----------------------------------------------------------------------
// $Id$

/**
 +------------------------------------------------------------------------------
 * YBlog附件下载模块
 +------------------------------------------------------------------------------
 * @author    yhustc <yhustc@gmail.com>
 * @version   $Id$
 +------------------------------------------------------------------------------
 */


class AttachAction extends BaseAction
{
	/**
     +----------------------------------------------------------
     * 用于SEO优化的空操作
     +----------------------------------------------------------
     * @access public 
     +----------------------------------------------------------
     */
	function _empty()
	{
		if(is_numeric(ACTION_NAME))
		{
			$attachDao = D("Attach");
			$attach = $attachDao->getById(ACTION_NAME);
			
			if(!$attach)
				$this->error("错误的参数");
			
			//这里只把下载次数加一,然后就header到真实地址
			$attachDao->setInc("downCount","`id`='".ACTION_NAME."'");
			header("location: ".str_replace("./",$this->options["siteurl"]."/",$attach["savepath"]).$attach["savename"]);
		}
		else
			$this->error("错误的参数");
	}
}
?>